Skip to content

M6c: @$var/#$var binding — tuple-stream joins#20

Merged
flearc merged 4 commits into
mainfrom
feature/m6c-binding
Jun 24, 2026
Merged

M6c: @$var/#$var binding — tuple-stream joins#20
flearc merged 4 commits into
mainfrom
feature/m6c-binding

Conversation

@flearc

@flearc flearc commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Implements JSONata v2.2.1's @$var (context/focus binding) and #$var (positional/index binding) path-step operators — the tuple-stream model behind joins — reusing the existing %-parent tuple-stream engine.

  • Parser (d950310): register @/# as bp-80 infix ops; validate the variable rhs (S0214); handle them inside flatten_path so paths stay flat (recurse lhs, mark focus/index/tuple on the last flat step) — leaving keepArray's predicate-nesting untouched. Only @ validates step position (S0215 after a predicate, S0216 after a sort); # indexes any step.
  • Evaluator (ffa74af): bind @$v focus (under $v, without advancing @ → cross-product joins) and #$v index (0-based) in eval_path_tuple (seeding + main loop); propagate a nested tuple-path's bindings so a predicated focus step (product@$p[…]) keeps $p; make </<=/>/>= return undefined on an undefined operand (faithful to jsonata).
  • Baseline (bda24c9): regen official-suite record, zero regressions.
  • Fidelity (8661647): comparison type-mismatch ("a" < 3) raises T2009 (not T2010), matching jsonata-js.

Results

  • Official suite 1211 → 1237 (+26, 72.5% → 74.0%); joins group 4 → 27/43.
  • 483 unit tests green; zero-regression guard green (%/parent/keepArray/predicates byte-identical).
  • Adversarial review vs genuine jsonata-js v2.2.1 confirmed: focus cross-product, single-side shorthand, focus-freezes-@, 3-way joins, global-counter 0-based index, all four error codes (S0214/5/6), and no perturbation of existing paths.

Deferred (documented, oracle-confirmed; → M6d)

  • Tuple-stream group-by — the {…} grouping operator doesn't propagate tuple bindings ($e/$i) into its key/value exprs; blocks ~8 employee-map-reduce cases (the "reduce" half of map-reduce). Needs a tuple-aware eval_group_step.
  • Reorder cases — a filter/sort before # ($[[1..4]]#$pos[$pos>=2], $^($)#$pos[$pos<3]) needs jsonata's ordered-stages interleaving. No crash; returns a structured value.

Test plan

  • busted spec/ — 483/0
  • busted spec/jsonata_suite_spec.lua — zero-regression guard green
  • bash scripts/run-suite.sh — 1237/1682, joins 27/43
  • Adversarial oracle fidelity review (jsonata@2.2.1)

🤖 Generated with Claude Code

flearc and others added 4 commits June 25, 2026 00:03
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…l_path_tuple

Bind the navigated value under $v without advancing @ (focus freezes the
context, making order@$o.product@$p a cross-product), and bind the 0-based
result index under $i. Also propagate the tuple stream out of a nested tuple
path (a focus/index step the parser wrapped to hold a predicate) so its $v
binding survives, and skip undefined operands in comparison type-checks
(jsonata returns undefined rather than raising T2010), so the deferred #$pos
reorder cases evaluate without crashing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…gressions

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…fidelity

The </<=/>/>= operator (reworked in M6c for undefined-operand handling)
conflated jsonata's T2010 (operand not number/string) with T2009 (operands
of different types). "a" < 3 now raises T2009, matching jsonata-js v2.2.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@flearc flearc merged commit 599b390 into main Jun 24, 2026
1 check passed
@flearc flearc deleted the feature/m6c-binding branch June 24, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant